﻿using System;
using Sorteo.BusinessComponents;

namespace Sorteo.UI.Reports
{
    public enum FilterOption {Todos, SoloFavorecidos, Coincidencia}

    public partial class ConcursantesForm : BaseForm
    {
        #region Constructors

        public ConcursantesForm()
        {
            InitializeComponent();
        }

        #endregion

        #region Properties: Public

        public FilterOption Option { get; set; }
        public int Promocion { get; set; }
        public string FiltroCedula { get; set; }
        public string FiltroNombre { get; set; }

        #endregion

        #region Event Handlers

        private void ConcusantesForm_Load(object sender, EventArgs e)
        {
            LoadPromociones();
        }

        private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            cedulaTextBox.Enabled = coincidenciasRadioButton.Checked;
            nombreTextBox.Enabled = coincidenciasRadioButton.Checked;
        }

        private void PrintButton_Click(object sender, EventArgs e)
        {
            if (todosRadioButton.Checked)
                Option = FilterOption.Todos;
            else if (favorecidosRadioButton.Checked)
                Option = FilterOption.SoloFavorecidos;
            else
                Option = FilterOption.Coincidencia;

            Promocion = Convert.ToInt32(promocionesComboBox.SelectedValue);
            FiltroCedula = cedulaTextBox.Text.Trim();
            FiltroNombre = nombreTextBox.Text.Trim();
            Close();
        }

        #endregion

        #region Methods: Non-Public

        private void LoadPromociones()
        {
            var promociones = BCPromocion.GetList();
            promocionesComboBox.DataSource = promociones;
            promocionesComboBox.DisplayMember = "Nombre";
            promocionesComboBox.ValueMember = "Id";
        }

        #endregion
    }
}
